

const date = new Date();
const endDate = date.toLocaleDateString();
const beginDate = new Date(date.setDate(date.getDate() - 10)).toLocaleDateString();
const url = 'https://yuqing.shangyuninfo.com';
const mySwiper = new Swiper('.swiper-container', {
    direction: 'vertical', // 垂直切换选项
    loop: true, // 循环模式选项
    autoplay: {
        delay: 2000,//1秒切换一次
    },
    simulateTouch:false,
    slidesPerView: 6,
    init:false,
})
// 热门信息
$.ajax({
    type: 'post',
    url: url + '/api/data-visualization/store/search',
    data: {
        similar: false,
        emotion: 'ALL',
        orderByType: 'SMART',
        matchingType: 'TITLE_AND_BODY',
        mediaType: 'ALL',
        minScore: 0,
        removeDuplicate: false,
        beginTime: beginDate,
        endTime: endDate,
        keyword: '',
        current: 1,
        size: 10,
    },
    success(res){
        // console.log(res);
        if(res.code == 200){
            $.each(res.data.records,function (index,value) {
                // console.log(value);
                $('.swiper-wrapper').append(`
                <div class="swiper-slide">
                    <div class="title">${value.title}</div>
                    <div class="time">${value.publishTime.substr(0,10)}</div>
                </div>`)
            })
        }
        mySwiper.init();
        // <div class="swiper-slide">Slide 1</div>
    },
    error(err){
        console.log(err);
    }
})
// 数量
$.ajax({
    type: 'post',
    url: url + '/api/data-visualization/analysis/emotional',
    data: {
        beginDate: '0',
        endDate: endDate,
        keyword: '',
    },
    success(res) {
        if (res.code == 200) {
            console.log(res.data);
            const num0 = res.data[0]['y']
            const num1 = res.data[1]['y']
            $('#dataNum').html(num0+num1)
        }
    },
    error(err) {
        console.log(err);
    }
})
